Use g_get_user_special_dir() to obtain the path for the DESKTOP directory.
authorMatthias Clasen <mclasen@redhat.com>
Thu, 7 Jun 2007 04:23:10 +0000 (04:23 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Thu, 7 Jun 2007 04:23:10 +0000 (04:23 +0000)
2007-06-06  Matthias Clasen  <mclasen@redhat.com>

        * gtk/gtkfilechooserbutton.c (model_add_special):
        * gtk/gtkfilechooserdefault.c (shortcuts_append_desktop):
        * gtk/gtkfilesystemunix.c (get_icon_name_for_directory):
        * gtk/gtkpathbar.c (_gtk_path_bar_set_file_system):
        Use g_get_user_special_dir() to obtain the path for the
        DESKTOP directory.

svn path=/trunk/; revision=18070

ChangeLog
gtk/gtkfilechooserbutton.c
gtk/gtkfilechooserdefault.c
gtk/gtkfilesystemunix.c
gtk/gtkpathbar.c

index b3ba658a7f3d376279b017e46da5d5773e34e85b..fe02d3c3c68fd793b6ec3a9b15a88498b9e1a713 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2007-06-06  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtkfilechooserbutton.c (model_add_special):
+       * gtk/gtkfilechooserdefault.c (shortcuts_append_desktop):
+       * gtk/gtkfilesystemunix.c (get_icon_name_for_directory):
+       * gtk/gtkpathbar.c (_gtk_path_bar_set_file_system):
+       Use g_get_user_special_dir() to obtain the path for the
+       DESKTOP directory.  
+
 2007-06-06  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/Makefile.am: Add the 16x16 version of gtk-select-color.png
index dfeba8d83ca5c5022fe916b6ed236349c18bb784..7b08b933e8fcf09818a48a8a56f1216811e02ca0 100644 (file)
@@ -1622,6 +1622,7 @@ model_add_special_get_info_cb (GtkFileSystemHandle *handle,
   GdkPixbuf *pixbuf;
   GtkFileSystemHandle *model_handle;
   struct ChangeIconThemeData *data = user_data;
+  const gchar *name;
 
   if (!data->button->priv->model)
     /* button got destroyed */
@@ -1659,9 +1660,13 @@ model_add_special_get_info_cb (GtkFileSystemHandle *handle,
       g_object_unref (pixbuf);
     }
 
-  gtk_list_store_set (GTK_LIST_STORE (data->button->priv->model), &iter,
-                     DISPLAY_NAME_COLUMN, gtk_file_info_get_display_name (info),
-                     -1);
+  gtk_tree_model_get (data->button->priv->model, &iter,
+                      DISPLAY_NAME_COLUMN, &name,
+                      -1);
+  if (!name)
+    gtk_list_store_set (GTK_LIST_STORE (data->button->priv->model), &iter,
+                       DISPLAY_NAME_COLUMN, gtk_file_info_get_display_name (info),
+                       -1);
 
 out:
   g_object_unref (data->button);
@@ -1717,15 +1722,9 @@ model_add_special (GtkFileChooserButton *button)
                          -1);
 
       button->priv->n_special++;
-
-#ifndef G_OS_WIN32
-      desktopdir = g_build_filename (homedir, DESKTOP_DISPLAY_NAME, NULL);
-#endif
     }
 
-#ifdef G_OS_WIN32
-  desktopdir = _gtk_file_system_win32_get_desktop ();
-#endif
+  desktopdir = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP);
 
   if (desktopdir)
     {
@@ -1734,7 +1733,6 @@ model_add_special (GtkFileChooserButton *button)
       struct ChangeIconThemeData *info;
 
       path = gtk_file_system_filename_to_path (button->priv->fs, desktopdir);
-      g_free (desktopdir);
       gtk_list_store_insert (store, &iter, pos);
       pos++;
 
index dd0cb692d333674c27ce0557a0c7edaf274c8e7b..e3791f9defbfcd8f35a2ed88c9d11ee924024b79 100644 (file)
@@ -1961,22 +1961,8 @@ shortcuts_append_desktop (GtkFileChooserDefault *impl)
 
   profile_start ("start", NULL);
 
-#ifdef G_OS_WIN32
-  name = _gtk_file_system_win32_get_desktop ();
-#else
-  home = g_get_home_dir ();
-  if (home == NULL)
-    {
-      profile_end ("end - no home directory!?", NULL);
-      return;
-    }
-
-  name = g_build_filename (home, "Desktop", NULL);
-#endif
-
+  name = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP);
   path = gtk_file_system_filename_to_path (impl->file_system, name);
-  g_free (name);
-
   shortcuts_insert_path (impl, -1, SHORTCUT_TYPE_PATH, NULL, path, _("Desktop"), FALSE, SHORTCUTS_DESKTOP);
   impl->has_desktop = TRUE;
 
index 38a6cd064b72cfe18882fd8e2d02c360c8ebdb48..b426afe764573106e8443f006907f424e93f5a91 100644 (file)
@@ -1601,17 +1601,12 @@ gtk_file_system_unix_filename_to_path (GtkFileSystem *file_system,
 static const char *
 get_icon_name_for_directory (const char *path)
 {
-  static char *desktop_path = NULL;
-
   if (!g_get_home_dir ())
     return "gnome-fs-directory";
 
-  if (!desktop_path)
-      desktop_path = g_build_filename (g_get_home_dir (), "Desktop", NULL);
-
   if (strcmp (g_get_home_dir (), path) == 0)
     return "gnome-fs-home";
-  else if (strcmp (desktop_path, path) == 0)
+  else if (strcmp (g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP), path) == 0)
     return "gnome-fs-desktop";
   else
     return "gnome-fs-directory";
index e63eeac9b97b83f89c2219a20f1ad58d2675cc7a..55c36522b50e7427c602ff1bc9237d3a5946bf38 100644 (file)
@@ -1675,13 +1675,17 @@ _gtk_path_bar_set_file_system (GtkPathBar    *path_bar,
   home = g_get_home_dir ();
   if (home != NULL)
     {
+      gchar *freeme = NULL;
+
       path_bar->home_path = gtk_file_system_filename_to_path (path_bar->file_system, home);
       /* FIXME: Need file system backend specific way of getting the
        * Desktop path.
        */
-      desktop = g_build_filename (home, "Desktop", NULL);
-      path_bar->desktop_path = gtk_file_system_filename_to_path (path_bar->file_system, desktop);
-      g_free (desktop);
+      desktop = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP);
+      if (desktop != NULL)
+        path_bar->desktop_path = gtk_file_system_filename_to_path (path_bar->file_system, desktop);
+      else 
+        path_bar->desktop_path = NULL;
     }
   else
     {